package com.superbytecode.cloud.albb.produce.service;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.albb.produce.service
 * @ClassName: MQProduceService
 * @Description: []
 * <p>
 * 发送消息：同步消息、异步消息和单向消息。其中前两种消息是可靠的，因为会有发送是否成功的应答
 * </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/24 11:49
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Service
public class AlbbMQProduceService {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public String sendSimpleMessages(Map<String, Object> messageBody) {
        try {
            rocketMQTemplate.convertAndSend("simple-topic", messageBody);
        } catch (Exception e) {
            return "simple message send failure，" + e.getMessage();
        }
        return "simple message send success!";
    }
}